<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>SST GLOVE - China Gloves Manufacturer. Heat Resistant Gloves. Cut Resistant Gloves</title>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.png"/>
    <link rel="stylesheet" href="assets/css/swap.css" />
    <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="assets/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="assets/css/owl.carousel.min.css"/>
    <link rel="stylesheet" href="assets/css/animate.min.css"/>
    <link rel="stylesheet" href="assets/css/jquery-ui.css"/>
    <link rel="stylesheet" href="assets/css/slick.css"/>
    <link rel="stylesheet" href="assets/css/chosen.min.css"/>
    <link rel="stylesheet" href="assets/css/pe-icon-7-stroke.css"/>
    <link rel="stylesheet" href="assets/css/magnific-popup.min.css"/>
    <link rel="stylesheet" href="assets/css/lightbox.min.css"/>
    <link rel="stylesheet" href="assets/js/fancybox/source/jquery.fancybox.css"/>
    <link rel="stylesheet" href="assets/css/jquery.scrollbar.min.css"/>
    <link rel="stylesheet" href="assets/css/mobile-menu.css"/>
    <link rel="stylesheet" href="assets/fonts/flaticon/flaticon.css"/>
    <link rel="stylesheet" href="assets/css/style.css"/>
</head>
<body class="productsgrid-page">

<header th:replace="head :: html"></header>

<div id="productListDiv"  class="main-content main-content-product left-sidebar">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="breadcrumb-trail breadcrumbs">
                    <ul class="trail-items breadcrumb">
                        <li class="trail-item trail-begin">
                            <a href="index.html">SST GLOVE</a>
                        </li>
                        <li class="trail-item trail-end active">
                            Product list
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="content-area shop-grid-content no-banner col-lg-9 col-md-9 col-sm-12 col-xs-12">
                <div class="site-main">
                    <h3 class="custom_blog_title">
                        Product list
                    </h3>
                    <ul class="row list-products auto-clear equal-container product-grid" id="product_list">

                    </ul>
                </div>
            </div>

            <!--左边的内容-->
            <div class="sidebar col-lg-3 col-md-3 col-sm-12 col-xs-12">
                <div class="wrapper-sidebar shop-sidebar">
                    <div class="widget woof_Widget" id="tagInfoWidget">

                        <div class="widget widget-categories">
                            <h3 class="widgettitle">Category</h3>
                            <ul class="list-categories">
                                <li>
                                    <input type="radio" name="type" id="type_all" value="allType" onclick='selectType(this)' checked="checked"/>
                                    <label for="type_all" class="label-text">
                                        ALL
                                    </label>
                                </li>
                                <hr />
                                <li>
                                    <input type="radio" name="type" id="hotResistant_all" value="hotResistant_all" onclick='selectType(this)'/>
                                    <label for="hotResistant_all" class="label-text">
                                        Heat Resistant Gloves
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_knit" value="hotResistant_knit" onclick='selectType(this)' />
                                    <label for="hotResistant_knit" class="label-text">
                                        Seamless Knit
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_gumming" value="hotResistant_gumming" onclick='selectType(this)'/>
                                    <label for="hotResistant_gumming" class="label-text">
                                        Dipping Series
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_sew" value="hotResistant_sew" onclick='selectType(this)'/>
                                    <label for="hotResistant_sew" class="label-text">
                                        Cut-and-Sewn
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="hotResistant_injection" value="hotResistant_injection" onclick='selectType(this)'/>
                                    <label for="hotResistant_injection" class="label-text">
                                        Molded Series
                                    </label>
                                </li>


                                <hr />
                                <li>
                                    <input type="radio" name="type" id="cutResistant_all" value="cutResistant_all" onclick='selectType(this)'/>
                                    <label for="cutResistant_all" class="label-text">
                                        Cut Resistant Gloves
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="cutResistant_pure"  value="cutResistant_pure" onclick='selectType(this)'/>
                                    <label for="cutResistant_pure" class="label-text">
                                        Uncoated Series
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type"  id="cutResistant_glue" value="cutResistant_glue" onclick='selectType(this)'/>
                                    <label for="cutResistant_glue" class="label-text">
                                        Coated Series
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="cutResistant_steel"  value="cutResistant_steel" onclick='selectType(this)'/>
                                    <label for="cutResistant_steel" class="label-text">
                                        Steel Mesh
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="cutResistant_sew"  value="cutResistant_sew" onclick='selectType(this)'/>
                                    <label for="cutResistant_sew" class="label-text">
                                        Cut-and-Sewn
                                    </label>
                                </li>

                                <hr />

                                <li>
                                    <input type="radio" name="type"  id="hardWearing" value="hardWearing" onclick='selectType(this)'/>
                                    <label for="hardWearing" class="label-text">
                                        Wear Resistant Gloves
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="antiCollision"  value="antiCollision" onclick='selectType(this)'/>
                                    <label for="antiCollision" class="label-text">
                                        Impact Resistant Gloves
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="coldProtective"  value="coldProtective" onclick='selectType(this)'/>
                                    <label for="coldProtective" class="label-text">
                                        Cold Resistant Gloves
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="antiChemical"  value="antiChemical" onclick='selectType(this)'/>
                                    <label for="antiChemical" class="label-text">
                                        Chemical Resistant Gloves
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="type" id="antiCuttingArm" value="antiCuttingArm" onclick='selectType(this)'/>
                                    <label for="antiCuttingArm" class="label-text">
                                        Cut Resistant Sleeves
                                    </label>
                                </li>

                                <li>
                                    <input type="radio" name="type" id="policeUse" value="policeUse" onclick='selectType(this)'/>
                                    <label for="policeUse" class="label-text">
                                        Gloves for Police
                                    </label>
                                </li>

                                <li>
                                    <input type="radio" name="type" id="pet"  value="pet" onclick='selectType(this)'/>
                                    <label for="pet" class="label-text">
                                        Pet Grooming Gloves
                                    </label>
                                </li>

                                <hr />

                                <li>
                                    <input type="radio" name="type" id="otherType" value="otherType" onclick='selectType(this)'/>
                                    <label for="otherType" class="label-text">
                                        Other
                                    </label>
                                </li>


                            </ul>
                        </div>

                        <div th:if=" ${session.user} == 'admin'">
                            <a data-toggle="modal" data-target="#myModal"> Add </a>
                            <br />
                            <input type="button" onclick="reloadCache()" value="reloadCache"/>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<div id="productDetailDiv" style="display:none" class="main-content main-content-details single left-sidebar">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <div class="breadcrumb-trail breadcrumbs">
                    <ul class="trail-items breadcrumb">
                        <li class="trail-item trail-begin">
                            <a href="index.html">SST GLOVE</a>
                        </li>
                        <li class="trail-item">
                            <a href="javascript:back2ProductList();">Product list</a>
                        </li>
                        <li class="trail-item trail-end active">
                            Product detail
                        </li>
                        <!--<li class="trail-item trail-end active">
                            <a href="javascript:back2ProductList();" style="color:red">Back to product list</a>
                        </li>-->
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="content-area content-details col-lg-9 col-md-8 col-sm-12 col-xs-12">
                <div class="site-main">
                    <div class="details-product">
                        <div class="details-thumd">
                            <div class="image-preview-container image-thick-box image_preview_container">
                                <img id="img_zoom"  src="" alt="img"/>
                                <!--<a href="#" class="btn-zoom open_qv"><i class="fa fa-search" aria-hidden="true"></i></a>-->
                            </div>
                            <!--<div class="product-preview image-small product_preview">
                                <div id="thumbnails" class="thumbnails_carousel owl-carousel" data-nav="true" data-autoplay="false" data-dots="false" data-loop="false" data-margin="10" data-responsive='{"0":{"items":3},"480":{"items":3},"600":{"items":3},"1000":{"items":3}}'>
                                    <a href="#" data-image="assets/images/productdetail/detail.jpg" data-zoom-image="assets/images/productdetail/detail.jpg" class="active">
                                        <img src="assets/images/productdetail/detail.jpg" data-large-image="assets/images/productdetail/detail.jpg" alt="img"/>
                                    </a>
                                    <a href="#" data-image="assets/images/details-item-2.jpg" data-zoom-image="assets/images/details-item-2.jpg">
                                        <img src="assets/images/details-item-2.jpg" data-large-image="assets/images/details-item-2.jpg" alt="img"/>
                                    </a>
                                    <a href="#" data-image="assets/images/details-item-3.jpg" data-zoom-image="assets/images/details-item-3.jpg">
                                        <img src="assets/images/details-item-3.jpg" data-large-image="assets/images/details-item-3.jpg" alt="img"/>
                                    </a>
                                    <a href="#" data-image="assets/images/details-item-4.jpg" data-zoom-image="assets/images/details-item-4.jpg">
                                        <img src="assets/images/details-item-4.jpg" data-large-image="assets/images/details-item-4.jpg" alt="img"/>
                                    </a>
                                </div>
                            </div>-->
                        </div>
                        <div class="details-infor">
                            <h1 class="product-title" id="prodcutname">
                            </h1>
                            <div class="stars-rating">
                                <div class="star-rating">
                                    <span id="productstar" class="star-5"></span>
                                </div>
                            </div>


                            <div class="availability">
                                Model:
                                <a href="#" id="modelno">CH-1301</a>
                            </div>


                            <div id="productattribute">
                                <!--<div class="availability">
                                    执行标准:
                                    <a href="#" >EN388 4543</a>
                                </div>-->
                            </div>

                            <div class="variations">
                                <div class="attribute attribute_color">
                                    <div class="availability">
                                        Size:
                                    </div>
                                    <div class="list-size list-item">
                                        <select title="size" id="availablesize">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="group-button">
                                <div class="quantity-add-to-cart">
                                    <button class="single_add_to_cart_button button">Contact us</button>
                                </div>
                            </div>

                            <div th:if=" ${session.user} == 'admin'" class="availability">
                                <a data-toggle="modal" data-target="#myModal"> 编辑 </a>
                            </div>
                        </div>
                    </div>
                    <div class="tab-details-product">
                        <ul class="tab-link">
                            <li class="active">
                                <a data-toggle="tab" aria-expanded="true" href="#product-descriptions">Description
                                </a>
                            </li>
                            <!--<li class="">
                                <a data-toggle="tab" aria-expanded="true" href="#information">Information </a>
                            </li>-->
                            <li class="">
                                <a data-toggle="tab" aria-expanded="true" href="#reviews">Customer evaluation</a>
                            </li>
                        </ul>
                        <div class="tab-container">
                            <div id="product-descriptions" class="tab-panel active">
                                <!--产品描述-->
                            </div>
                            <!--<div id="information" class="tab-panel">
                                <table class="table table-bordered">
                                    <tr>
                                        <td>Size</td>
                                        <td> XS / S / M / L </td>
                                    </tr>
                                    <tr>
                                        <td>Color</td>
                                        <td>White/ Black/ Teal/ Brown</td>
                                    </tr>
                                    <tr>
                                        <td>Properties</td>
                                        <td>Colorful Dress</td>
                                    </tr>
                                </table>
                            </div>-->
                            <div id="reviews" class="tab-panel">
                                <div class="reviews-tab">
                                    <div class="comments">
                                        <h2 class="reviews-title">
                                            1 review for
                                            <span>Ehpro Cold Steel</span>
                                        </h2>
                                        <ol class="commentlist">
                                            <li class="conment">
                                                <div class="conment-container">
                                                    <a href="#" class="avatar">
                                                        <img src="assets/images/avartar.jpg" alt="img"/>
                                                    </a>
                                                    <div class="comment-text">
                                                        <div class="stars-rating">
                                                            <div class="star-rating">
                                                                <span class="star-5"></span>
                                                            </div>
                                                            <div class="count-star">
                                                                (1)
                                                            </div>
                                                        </div>
                                                        <p class="meta">
                                                            <strong class="author">Cobus Bester</strong>
                                                            <span>-</span>
                                                            <span class="time">June 7, 2013</span>
                                                        </p>
                                                        <div class="description">
                                                            <p>Simple and effective design. One of my favorites.</p>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                        </ol>
                                    </div>
                                    <div class="review_form_wrapper">
                                        <div class="review_form">
                                            <div class="comment-respond">
                                                <span class="comment-reply-title">Add a review </span>
                                                <form class="comment-form-review">
                                                    <p class="comment-notes">
                                                        <span class="email-notes">Your email address will not be published.</span>
                                                        Required fields are marked
                                                        <span class="required">*</span>
                                                    </p>
                                                    <div class="comment-form-rating">
                                                        <label>Your rating</label>
                                                        <p class="stars">
                                        						<span>
                                        							<a class="star-1" href="#"></a>
                                        							<a class="star-2" href="#"></a>
                                        							<a class="star-3" href="#"></a>
                                        							<a class="star-4" href="#"></a>
                                        							<a class="star-5" href="#"></a>
                                        						</span>
                                                        </p>
                                                    </div>
                                                    <p class="comment-form-comment">
                                                        <label>
                                                            Your review
                                                            <span class="required">*</span>
                                                        </label>
                                                        <textarea title="review" id="comment" name="comment" cols="45" rows="8"></textarea>
                                                    </p>
                                                    <p class="comment-form-author">
                                                        <label>
                                                            Name
                                                            <span class="">*</span>
                                                        </label>
                                                        <input title="author" id="author" name="author" type="text" value="" />
                                                    </p>
                                                    <p class="comment-form-email">
                                                        <label>
                                                            Email
                                                            <span class="">*</span>
                                                        </label>
                                                        <input title="email" id="email" name="email" type="email" value=""  />
                                                    </p>
                                                    <p class="form-submit">
                                                        <input name="submit" type="submit" id="submit" class="submit" value="Submit" />
                                                    </p>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div style="clear: left;"></div>
                </div>
            </div>
            <div class="sidebar sidebar-details col-lg-3 col-md-4 col-sm-12 col-xs-12">
                <div class="wrapper-sidebar">
                    <!--<div class="widget widget-categories">
                        <h3 class="widgettitle">Categories</h3>
                        <ul class="list-categories">
                            <li>
                                <input type="checkbox" id="cb1" />
                                <label for="cb1" class="label-text">
                                    New Arrivals
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb2" />
                                <label for="cb2" class="label-text">
                                    Beverage
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb3" />
                                <label for="cb3" class="label-text">
                                    Citrus
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb4" />
                                <label for="cb4" class="label-text">
                                    Creamy
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb5" />
                                <label for="cb5" class="label-text">
                                    Best Seller
                                </label>
                            </li>
                            <li>
                                <input type="checkbox" id="cb6" />
                                <label for="cb6" class="label-text">
                                    Fruity
                                </label>
                            </li>
                        </ul>
                    </div>-->
                    <div class="widget widget-related-products">
                        <h3 class="widgettitle">Recommend Products</h3>
                        <div  class="slider-related-products owl-slick nav-top-right equal-container"  data-slick ='{"autoplay":false, "autoplaySpeed":1000, "arrows":true, "dots":false, "infinite":true, "speed":800, "rows":1}' data-responsive='[{"breakpoint":"2000","settings":{"slidesToShow":1 }},{"breakpoint":"992","settings":{"slidesToShow":2}}]'>
                            <div id="relativeList">

                            </div>
                        </div>
                    </div>
                    <!--<div class="widget widget-banner">
                        <a href="#">
                            <img src="assets/images/widget-banner.jpg" alt="img"/>
                        </a>
                    </div>-->
                    <!--<div class="widget widget-testimonials">
                        <h3 class="widgettitle">Testimonials</h3>
                        <div class="slider-related-products owl-slick nav-top-right"  data-slick ='{"autoplay":false, "autoplaySpeed":1000, "arrows":true, "dots":false, "infinite":true, "speed":800, "rows":1}' data-responsive='[{"breakpoint":"991","settings":{"slidesToShow":1 }}]'>
                            <div class="testimonials-item">
                                <div class="Testimonial-inner">
                                    <div class="comment">
                                        Donec ligula mauris, posuere sed tincidunt a, facilisis id enim. Class aptent taciti sociosqu ad litora torquent per conubia.
                                    </div>
                                    <div class="author">
                                        <div class="avt">
                                            <img src="assets/images/member1.jpg" alt="img"/>
                                        </div>
                                        <h3 class="name">
                                            Adam Smith
                                            <span class="position">
                                                CEO/Founder Apple
                                            </span>
                                        </h3>

                                    </div>
                                </div>
                            </div>
                            <div class="testimonials-item">
                                <div class="Testimonial-inner">
                                    <div class="comment">
                                        Donec ligula mauris, posuere sed tincidunt a, facilisis id enim. Class aptent taciti sociosqu ad litora torquent per conubia.
                                    </div>
                                    <div class="author">
                                        <div class="avt">
                                            <img src="assets/images/member2.jpg" alt="img"/>
                                        </div>
                                        <h3 class="name">
                                            Tom Milikin
                                            <span class="position">
                                                CEO/Founder Apple
                                            </span>
                                        </h3>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>-->
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <form id="editProduct-form">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        添加产品
                    </h4>
                </div>
                <div class="modal-body">


                    <table>
                        <tr>
                            <td>产品名称：<br />
                                <input type="hidden" id="edit_ProductId" name="productId" value="0" />
                                <input type="text" id="edit_ProductName" name="productname" value="" /></td>
                            <td>星星数：<br />
                                <input type="text" id="edit_Productstar" name="productstar" value="5" /></td>
                        </tr>

                        <tr>

                            <td>
                                缩略图：<br />
                                <img src="" alt="" width="100px" id="img2"/>
                                <input type="file" id="file1" name="file" onchange="upload()" />

                            </td>
                            <td>

                            </td>
                        </tr>

                        <tr>
                            <td><!--缩略图：<br />--><input type="hidden" name="thumbnailsPicurl" id="edit_ThumbnailPic" value="" /></td>
                            <td><!--详细图：<br />--><input type="hidden" name="detailpicurl" id="edit_DetailPic" value="" /></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品属性：<br /><input style="width: 100%" type="text" name="productattribute" id="edit_Productattribute" value="" /></td>
                        </tr>

                        <tr>
                            <td>产品型号：<br /><input type="text" name="modelno" id="edit_Modelno" value="" /></td>
                            <td>尺寸：<br /><input type="text" name="availableSize" id="edit_AvailableSize" value="" /></td>
                        </tr>

                        <tr>
                            <td colspan="2">产品标签：<br /><input style="width: 100%" type="text" name="producttags" id="edit_ProductTags" value="" /></td>
                        </tr>

                        <tr><td colspan="2">产品描述：<textarea id="edit_PorductDesc" name="productdesc" rows="8" cols="30" value="" /></td></tr>
                    </table>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" onclick="saveProduct()" class="btn btn-primary">
                        保存
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->



<div th:replace="foot :: html"></div>

<script src="assets/js/jquery-1.12.4.min.js"></script>
<script src="assets/js/jquery.plugin-countdown.min.js"></script>
<script src="assets/js/jquery-countdown.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/owl.carousel.min.js"></script>
<script src="assets/js/magnific-popup.min.js"></script>
<script src="assets/js/isotope.min.js"></script>
<script src="assets/js/jquery.scrollbar.min.js"></script>
<script src="assets/js/jquery-ui.min.js"></script>
<script src="assets/js/mobile-menu.js"></script>
<script src="assets/js/chosen.min.js"></script>
<script src="assets/js/slick.js"></script>
<script src="assets/js/jquery.elevateZoom.min.js"></script>
<script src="assets/js/jquery.actual.min.js"></script>
<script src="assets/js/fancybox/source/jquery.fancybox.js"></script>
<script src="assets/js/lightbox.min.js"></script>
<script src="assets/js/owl.thumbs.min.js"></script>
<script src="assets/js/jquery.scrollbar.min.js"></script>
<script src="assets/js/frontend-plugin.js"></script>

<script th:inline="javascript">

    /*<![CDATA[*/
    $(document).ready(function() {

        var tag = getQueryVariable("tag");
        /*if("" == tag){
            tag = "allType";
        }*/
        if(tag != null && "" != tag){
            $("#"+tag+"").prop("checked", "checked");
        }

        loadProduct(tag);

        // loadTagInfo();
    });

    var productinfos;
    function back2ProductList(){
        $("#productDetailDiv").hide();
        $("#productListDiv").show();
    }
    function showProductDetail(id){
        $("#productListDiv").hide();
        // 设置属性
        for (var item of productinfos) {
            if(item.id == id){
                $("#prodcutname").text(item.productname);
                $("#productstar" ).attr( "class", "star-"+item.productstar);
                $("#modelno").text(item.modelno);
                $("#standard").text(item.standard);
                $("#img_zoom").attr("src","/api/image/productImage.do?imageName="+item.thumbnailspicurl);
                var relativeid = item.relativeid;
                $("#productdetail_list").html("");
                $.post("/api/product/searchProduct.do",
                        { //需要传入后代的数据
                            productids: relativeid
                        },
                        function (message) {
                            // $("#title_productDetail").text(message.productinfo.productname);
                            // $("#img_productDetail").attr("src", "assets/images/productdetail/" + message.productpicinfoList[0].picurl);
                            // $("#star_productDetail").attr("class", "star-" + message.productinfo.productstar);
                            // $("#starCount_productDetail").text(message.productinfo.productstar);
                            // $("#oldprice_productDetail").text("$" + message.productinfo.oriprice);
                            // $("#newprice_productDetail").text("$" + message.productinfo.price);
                            var productHtml = "";
                            for(let i = 0; i < message.productinfoList.length; i++){
                                var productinfo = message.productinfoList[i];
                                productHtml +=
                                        '<div class="product-item style-1"><div class="product-inner equal-element">' +
                                        '<div class="product-top"><div class="flash"><span class="onnew"><span class="text">new</span></span></div></div><div class="product-thumb">' +
                                        '<div class="thumb-inner"><a href="productdetails_leftsidebar.html?id='+productinfo.id+'"><img id="img_productDetail" src="' + message.pic + '" alt="img"/></a></div></div><div class="product-info">' +
                                        '<h5  class="product-name product_title">' + productinfo.productname + '</h5><div class="group-info"><div class="stars-rating">' +
                                        '<div class="star-rating"><span class="star-' + productinfo.productstar + '"></span></div></div>' +
                                        '</div></div></div></div>';
                            }
                            $("#relativeList").html(productHtml);
                        });
                if(item.productattribute != null) {
                    var attributesArray = item.productattribute.split(";");
                    var attributeHtml = "";
                    if (attributesArray != null && attributesArray.length > 0) {
                        for (var i = 0; i < attributesArray.length; i++) {
                            attributeHtml += '<div class="availability">'
                                    + attributesArray[i].split(":")[0]
                                    + ':<a href="#" >'
                                    + attributesArray[i].split(":")[1]
                                    + '</a></div>';
                            $("#productattribute").html(attributeHtml);
                        }
                    }
                }

                // 拆分
                if(item.availablesize != null){
                    var sizeHtml = "";
                    var sizeArray = item.availablesize.split(";");
                    sizeArray.forEach(function (element, index, array) {
                        sizeHtml += "<option>" + element + "</option>";
                    });
                    $("#availablesize").html(sizeHtml);
                }

                $("#product-descriptions").html(item.productdesc);
                $("#edit_ProductId").val(item.id);
                $("#edit_Productstar").val(item.productstar);
                $("#edit_Productattribute").val(item.productattribute);
                $("#edit_availablesize").val(item.availablesize);



                $("#edit_ProductName").val(item.productname);
                $("#edit_ProductType").val(item.productType);
                $("#edit_PorductDesc").val(item.productdesc);
                $("#edit_ThumbnailPic").val(item.thumbnailspicurl);
                $("#edit_ProductTags").val(item.producttags);
                $("#edit_relativeid").val(item.relativeid);

                $("#edit_Size").val(item.availablesize);
                $("#edit_Modelno").val(item.modelno);

                $("#edit_DetailPic").val(item.thumbnailspicurl);
                scrollTo(0,0);
                $("#productDetailDiv").show();
            }
        }

    }

    function reloadCache(){
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/api/product/reloadCache.do" ,//url
            success: function (message) {
                alert("刷新成功");
                window.location.reload();

            },
            error : function() {
                alert("刷新异常！");
            }
        });
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;
    }

    function saveProduct() {


        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "/api/product/saveProduct.do" ,//url
            data: $('#editProduct-form').serialize(),
            success: function (message) {
                var result = message;
                alert(result.resultMessage);
                if (result.result) {
                    // 刷新页面
                    window.location.reload();
                }

            },
            error : function() {
                alert("保存异常！");
            }
        });
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;
    }


    function loadProduct(tag) {
        $("#product_list").html("loading...");
        $.post("/api/product/searchProduct.do",
                { //需要传入后代的数据
                    tags:tag
                },
                function (message) {
                    var result = message;
                    var productHtml ="";
                    productinfos = result.productinfoList;
                    for (var i in result.productinfoList) {

                        productHtml +=
                                '<li class="product-item col-lg-4 col-md-6 col-sm-6 col-xs-6 col-ts-12 style-1">' +
                                '<div class="product-inner equal-element"><div class="product-top"><div class="flash"><span class="onnew"><span class="text">new</span></span></div>' +
                                '</div><div class="product-thumb"><div class="thumb-inner"><a onclick=showProductDetail('+result.productinfoList[i].id+')>' +
                                '<img src=/api/image/productImage.do?imageName='+result.productinfoList[i].thumbnailspicurl+' alt="img"/></a><div class="thumb-group">' +
                                '<a href="#" class="button quick-wiew-button" productid="'+result.productinfoList[i].id+'">Quick View</a></div></div></div><div class="product-info">' +
                                '<label  style="color: black">'+ result.productinfoList[i].productname +'</label><div class="group-info">' +
                                '<div class="stars-rating"><div class="star-rating"><span class="star-'+result.productinfoList[i].productstar+'"></span>' +
                                '</div></div><div class="price"><ins>'+result.productinfoList[i].modelno+'</ins></div></div>'
                            +'</div></div></li>';
                    }
                    $("#product_list").html(productHtml);

                }
        );
        // 必须返回false，否则表单会自己再做一次提交操作，并且页面跳转
        return false;
    }



    var tag ="";
    
    function selectType(o) {
        /*第二层*/
        changeParam("tag", $(o).val());
        // 重新加载
        loadProduct(getQueryVariable("tag"));
    }


    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return "";
    }



    function changeParam(name, value) {
        var url = window.location.href;
        var newUrl = "";
        var reg = new RegExp("(^|)" + name + "=([^&]*)(|$)");
        var tmp = name + "=" + value;
        if (url.match(reg) != null) {
            newUrl = url.replace(eval(reg), tmp);
        } else {
            if (url.match("[\?]")) {
                newUrl = url + "&" + tmp;
            } else {
                newUrl = url + "?" + tmp;
            }
        }
        history.replaceState(null, null, newUrl);
    }

    function upload(){
        var files = $('#file1')[0].files
        if(files.length <= 0) {
            return alert('请选择要上传的文件')
        }
        console.log('ok!');
        var fd = new FormData();
        fd.append('file',files[0]);
        $('#img2').attr('src', window.URL.createObjectURL(files[0]));
        // 发起jquery的ajax请求
        $.ajax({
            method:'POST',
            url:'/api/product/saveProductImg.do',
            data:fd,
            // 不对FromData中的url进行编码，原样发送
            processData:false,
            // 不修改contentType属性，使用默认
            contentType:false,
            success: function(res) {
                $('#edit_ThumbnailPic').val(res.fileName);
                // 将图片文件显示在网页中
                // $('#img2').attr('src','http://www.liulongbin.top:3006' + res.url)
            }
        });
        return false;
    }

    /*]]>*/


</script>


</body>
</html>